package logic

import (
	"B/renrenzhuB_srv/model/mysql"
	"context"

	"B/renrenzhuB_srv/internal/svc"
	"B/renrenzhuB_srv/renrenzhuB"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserListLogic) UserList(in *renrenzhuB.UserListRequest) (*renrenzhuB.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var user mysql.User
	list := user.List(in.Status)
	var users []*renrenzhuB.UserList
	for _, u := range list {
		users = append(users, &renrenzhuB.UserList{
			Tel:      u.Username,
			Password: u.Password,
			Status:   u.Status,
		})
	}
	return &renrenzhuB.UserListResponse{List: users}, nil
}
